home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
pcr
/
pcr4_4.lha
/
DIST
/
gc
/
GCmark_roots.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-11
|
4KB
|
121 lines
/* begincopyright
Copyright (c) 1988,1990 Xerox Corporation. All rights reserved.
Use and copying of this software and preparation of derivative works based
upon this software are permitted. Any distribution of this software or
derivative works must comply with all applicable United States export
control laws. This software is made available AS IS, and Xerox Corporation
makes no warranty about the software, its performance or its conformity to
any specification. Any person obtaining a copy of this software is requested
to send their name and post office or electronic mail address to:
PCR Coordinator
Xerox PARC
3333 Coyote Hill Rd.
Palo Alto, CA 94304
Parts of this software were derived from code bearing the copyright notice:
Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
This material may be freely distributed, provided this notice is retained.
This material is provided as is, with no warranty expressed or implied.
Use at your own risk.
endcopyright */
# include "xr/GCPrivate.h"
/*
* Boehm, April 17, 1990 5:36:21 pm PDT
*/
/* Call the mark routines (GC_tl_mark for a single pointer, GC_mark_all */
/* on groups of pointers) on every top level accessible pointer. */
/* Caller will presumably call mark to mark everything reachable */
/* through them. */
/* This is source language specific. The following works for PCR. */
/* Mark_clean specifies whether roots on clean pages should be */
/* considered. */
void GC_mark_roots(mark_clean)
bool mark_clean;
{
int * dummy = 0;
/* Make sure mark stack is empty */
if (GC_mark_stack_top != GC_mark_stack_bottom) {
GC_abort("GC_mark_roots 0");
}
/*
* We don't need to mark from registers, since they are also
* in the thread structure or on the stack.
*/
/* mark from the static and bss areas of each module */
{
struct data_list *d, *XR_get_data_list();
int i;
for (i=0; d = XR_get_data_list(i); i++) {
GC_tl_mark_all_but_gc(d->start, d->end, mark_clean);
}
}
/* mark from the various other stacks */
XR_ApplyToSysMem (GC_tl_mark_all_but_gc, mark_clean);
}
/* Top level mark routine. Mark from the object pointed to by p. */
/* This is defined here, since alignment is not an explicit parameter. */
/* Thus the routine is language specific. */
/* Tl_mark is normally called by mark_regs, and thus must be defined. */
void GC_tl_mark(p)
word * p;
{
word * q;
q = p;
# ifdef INTERIOR_STACK_POINTERS
GC_mark_all(&q, (&q)+1, ALIGNMENT, ALL_POINTERS, TRUE);
# else
GC_mark_all(&q, (&q)+1, ALIGNMENT, ALL_POINTERS, FALSE);
# endif
}
/* Interface to mark_all that does not require alignment parameter. */
/* Defined here to keep mach_dep.c programming language independent. */
void GC_tl_mark_all(b,t)
word *b, *t;
{
bool coerce_pointers = FALSE;
# ifdef INTERIOR_STACK_POINTERS
if (b >= (word *)GC_heaplim /* stack area */) {
coerce_pointers = TRUE;
}
# endif INTERIOR_STACK_POINTERS
GC_mark_all(b, t, ALIGNMENT, ALL_POINTERS, coerce_pointers);
}
/* Similar to GC_tl_mark_all, except that gc data area is explicitly */
/* skipped over if it is encountered. */
/* Always returns TRUE, to keep XR_ApplyToSysMem happy. */
bool GC_tl_mark_all_but_gc(b,t,mark_clean)
word *b, *t;
{
bool coerce_pointers = FALSE;
# ifdef INTERIOR_STACK_POINTERS
if (b >= (word *)GC_heaplim /* stack area */) {
coerce_pointers = TRUE;
}
# endif INTERIOR_STACK_POINTERS
if (b <= &GC_first_global && &GC_last_global <= t) {
GC_mark_all(b, &GC_first_global, ALIGNMENT, mark_clean, FALSE);
GC_mark_all(&GC_last_global, t, ALIGNMENT, mark_clean, FALSE);
} else {
GC_mark_all(b, t, ALIGNMENT, mark_clean, coerce_pointers);
}
return(TRUE);
}